<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>8-set数据结构</title>
</head>
<body>
    <script>
        //set里面的值唯一的,可以用来去重复
        let nums = new Set([1,2,3,3,3,4,4]);
        console.log(nums);//set[1,2,3,4]
        //循环
        nums.forEach((val)=>{
            console.log(val);
        });
        let empty = new Set();
        //链式操作
        empty.add(1).add(2).add(3);
        console.log(empty);
        //删除
        empty.delete(1);
        console.log(empty);
        //判断是否有
        var x = empty.has(1);
        console.log(x);//false
        //清除所有
        empty.clear();

    </script>
</body>
</html>